package com.bitcola.security.activity.controller;

import com.bitcola.security.activity.biz.TransformBiz;
import com.bitcola.security.common.constant.BalanceTypeConstants;
import com.bitcola.security.common.context.BaseContextHandler;
import com.bitcola.security.common.exception.ParamLimitException;
import com.bitcola.security.common.msg.AppResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;


/**
 *  @author wx
 * @create 2018-11-30 11:16
 **/
@RestController
@RequestMapping("transform")
public class TransfromController {

    @Autowired
    TransformBiz transformBiz;

    @RequestMapping(value = "transform")

    public AppResponse transform(String coinCode, BigDecimal amount,String balanceType){


        String userId = BaseContextHandler.getUserID();

        if(balanceType.equals(BalanceTypeConstants.APPLY_AMOUNT)||BalanceTypeConstants.MINING.equals(balanceType)) {
            if (amount.compareTo(BigDecimal.ZERO) <= 0) throw new ParamLimitException("");
            transformBiz.transfrom(userId, amount, coinCode,balanceType);
        }

        return AppResponse.ok();

    }

}
